package worldinruin.gui.imp.gameview;
import java.awt.Dimension;

import javax.swing.GroupLayout;
import javax.swing.JComponent;
import javax.swing.JLabel;

import worldinruin.core.ISoldier;
import worldinruin.resources.IconMap;
import worldinruin.utils.ResizableLabel;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class UnitInformationPanel extends javax.swing.JPanel {
	private ResizableLabel unitLabel;
	private int amount;
	private JLabel amountLabel;
	private ISoldier soldier;
	
	/**
	 * Creates a unit information panel.
	 * @param soldier Soldier type.
	 * @param amount Soldier amount.
	 */
	public UnitInformationPanel(ISoldier soldier, int amount) {
		super();
		this.soldier = soldier;
		this.amount = amount;
		initGUI();
		setupGUI();
	}
	
	/**
	 * Setup GUI.
	 */
	private void setupGUI() {
		//unitLabel.setImage(IconMap.getInstance().getIcon(soldier.getSoldierType()).getImage());
		//unitLabel.setIcon());
		amountLabel.setText(amount + "");	
	}
	
	/**
	 * Initiate GUI.
	 */
	private void initGUI() {
		try {
			GroupLayout thisLayout = new GroupLayout((JComponent)this);
			this.setLayout(thisLayout);
			setPreferredSize(new Dimension(250, 200));
			{
				unitLabel = new ResizableLabel(IconMap.getInstance().getIcon(soldier.getSoldierType()).getImage());
				//unitLabel = new ResizableLabel();
				//unitLabel.setVerticalTextPosition(JLabel.BOTTOM);
				//unitLabel.setHorizontalTextPosition(JLabel.CENTER);
				//unitLabel.setBounds(12, 12, 50, 50);
				//unitLabel.setHorizontalAlignment(SwingConstants.CENTER);
				unitLabel.setVerticalTextPosition(JLabel.BOTTOM);
				unitLabel.setHorizontalTextPosition(JLabel.RIGHT);
			}
			{
				amountLabel = new JLabel();
			}
				thisLayout.setVerticalGroup(thisLayout.createSequentialGroup()
					.addContainerGap(22, 22)
					.addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
					    .addComponent(unitLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 110, GroupLayout.PREFERRED_SIZE)
					    .addComponent(amountLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 57, GroupLayout.PREFERRED_SIZE))
					.addContainerGap(38, 38));
				thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup()
					.addComponent(unitLabel, GroupLayout.PREFERRED_SIZE, 114, GroupLayout.PREFERRED_SIZE)
					.addGap(0, 26, GroupLayout.PREFERRED_SIZE)
					.addComponent(amountLabel, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(23, 23));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * Update GUI.
	 */
	private void updateGUI() {
		unitLabel.setText(amount + "");	
	}
}
